package org.stvd.controller.logs;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.stvd.controller.BaseController;
import org.stvd.core.dto.QueryResult;
import org.stvd.entities.logs.SysOperLog;
import org.stvd.service.logs.SysOperLogService;

/**
 * @Title: SysOperLogController
 * @Description: 系统操作日志控制类
 * @author houzx
 * @date 2020年9月3日
 */
@Controller
@RequestMapping("logs/operlog")
public class SysOperLogController extends BaseController{

    @Autowired
    private SysOperLogService sysOperLogService;
    
    private String tmpURL = "/logs/operlog/";
    
    /**
     * @Description: 操作日志管理
     * @param sysOperLog
     * @return
     */
    @RequestMapping(value="manage")
    public String onSysOperlogManage(@ModelAttribute("sysOperLog") SysOperLog sysOperLog) {
        QueryResult<SysOperLog> queryResult = sysOperLogService.queryOperLogResult((pageNo - 1) * pageSize, pageSize,
                sysOperLog.getTitle(), sysOperLog.getBusinessType(), sysOperLog.getOperatorType(), sysOperLog.getOperIp(), 
                sysOperLog.getOperName(), sysOperLog.getStatus(), sysOperLog.getQueryStartDate(), sysOperLog.getQueryEndDate());
        map.put("queryResult", queryResult);
        return tmpURL + "SysOperLogManage.html";
    }
    
    /**
     * @Description: 操作日志详情
     * @param operId 操作ID
     * @return
     */
    @RequestMapping(value="detail/{operId}")
    public String onSysOperlogDetail(@PathVariable Long operId) {
        SysOperLog sysOperLog = sysOperLogService.findByPk(SysOperLog.class, operId);
        map.put("sysOperLog", sysOperLog);
        return tmpURL + "SysOperLogDetail.html";
    }
}
